import axios from "axios";
import useLoginStore from "@/store/login";

const request = axios.create({
    baseURL: "/mock",
    timeout: 20000,
});
request.interceptors.request.use(
    (config) => {
        const loginStore=useLoginStore()
        const access_token=loginStore.access_token_zww_2
        // const access_token='30b129e1-45d4-4b64-a522-612499b3316b'
        if(access_token){
            (config.headers as any).token=access_token
        }
        // config.params={
        //     access_token
        // }
        return config;
    },
    (err) => {
        return Promise.reject(err);
    }
);

request.interceptors.response.use(
    (res) => {
        return res.data.data;
    },
    (err) => {
        return Promise.reject(err);
    }
);

export default request;
